package com.xc.hotelmgr.webapi.modules.sys.service.impl;

import com.xc.hotelmgr.webapi.modules.ht.entity.HtHotelinfoEntity;
import com.xc.hotelmgr.webapi.modules.ht.entity.HtPhysicalRoomEntity;
import com.xc.hotelmgr.webapi.modules.ht.service.HtHotelinfoService;
import com.xc.hotelmgr.webapi.modules.ht.service.HtPhysicalRoomService;
import com.xc.hotelmgr.webapi.modules.sys.entity.ExcelPojo;
import com.xc.hotelmgr.webapi.modules.sys.service.ExcelUpdateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExcelUpdateServiceImpl implements ExcelUpdateService {

    @Autowired
    private HtHotelinfoService htHotelinfoService;

    @Autowired
    private HtPhysicalRoomService htPhysicalRoomService;

    @Async
    @Override
    public void excelUpdate(ExcelPojo excelPojo) {
        List<HtHotelinfoEntity> htHotelinfoEntities = excelPojo.getHtls();
        List<HtPhysicalRoomEntity> htPhysicalRoomEntities = excelPojo.getRooms();
        htHotelinfoService.updateBatchById(htHotelinfoEntities, 200);
        htPhysicalRoomService.updateBatchById(htPhysicalRoomEntities, 200);
    }
}
